<?php
/*****************************************************
 * Project: PPDAO
 * 
 * 
 * Author: Ivan Femia
 * Last modify by: Ivan Femia
 * 
 ***************************************************** 
 * 
 * Main index
 * 
 *****************************************************/

if ( isset( $_GET['lastAction'] ) ) {
	$fileName = '../mvc/model/'.$_GET['lastAction'].'Model.php';
	
	if ( file_exists($fileName)) {
		
		include_once $fileName;
	}
}
include_once '../config/parameters.inc.php';


// Check the view that have to be shown
if ( !isset($_GET['page']) || $_GET['page'] == '' ) {
	$viewName = '../mvc/view/'.$_DEFAULT_VIEW.'View.php';
} else {
	$viewName = '../mvc/view/'.$_GET['page'].'View.php';
}

if ( !file_exists($viewName) ) {
	$viewName = '../mvc/view/defaultView.php';
}

/*** Retrive data from session ***/
include_once '../mvc/view/inc_errorView.php';
/*** Retrive data from session ***/
include_once '../mvc/view/inc_paramView.php';

// TODO: common page layout managing

include_once $viewName;